//
//  ZZMainTabBarController.m
//  OCFrame
//
//  Created by hfzhangzhang on 2017/1/4.
//  Copyright © 2017年 hfzhangzhang. All rights reserved.
//

#import "ZZMainTabBarController.h"
#import "CompanyViewController.h"
#import "MessageViewController.h"
#import "PositionViewController.h"
#import "UserCenterViewController.h"

@interface ZZMainTabBarController ()
{
}

@property (strong, nonatomic) NSDate *lastPlaySoundDate;
@end

@implementation ZZMainTabBarController

+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    static ZZMainTabBarController *ZZMainTabBarController = nil;
    dispatch_once(&onceToken, ^{
        ZZMainTabBarController = [[self alloc] init];
    });
    
    return ZZMainTabBarController;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self addChildViewControllers];
}

/// 添加子控制器
-(void)addChildViewControllers{
    
    NSArray *configs = @[
@[@"CompanyViewController",@"tab_bar_company_normal",@"tab_bar_company_selected"],
@[@"PositionViewController",@"tab_bar_position_normal",@"tab_bar_position_selected"],
@[@"MessageViewController",@"tab_bar_message_normal",@"tab_bar_message_selected"],
@[@"UserCenterViewController",@"tab_bar_user_normal",@"tab_bar_user_selected"],
                    ];
    for (NSArray* vcArr in configs) {
        Class clz = NULL;
        if (NSClassFromString(vcArr[0])) {
            clz = NSClassFromString(vcArr[0]);
            UIViewController *vc = [[clz alloc] init];
            if ([vc isKindOfClass:[UIViewController class]]) {
                vc.tabBarItem.imageInsets = UIEdgeInsetsMake(7, 0, -7, 0);
                vc.tabBarItem.image = [[UIImage imageNamed:vcArr[1]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
                vc.tabBarItem.selectedImage =[[UIImage imageNamed:vcArr[2]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
                [vc.tabBarItem.image setAccessibilityIdentifier:vcArr[1]];
                [self addChildViewController:[[UINavigationController alloc] initWithRootViewController:vc]];
            }
        }
        
    }
}





@end
